﻿using Factory.MasterData.MaterialClassifications;
using Factory.MasterData.MaterialClassifications.Dto;
using Factory.MasterData.Materials;
using Microsoft.AspNetCore.Mvc;
using NuGet.Protocol.Core.Types;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;

namespace Factory.Web.Controllers.MasterData
{
    public class MaterialController : Controller
    {
        #region 控制器
        public readonly IMaterialClassificationAppService service;

        public MaterialController(IMaterialClassificationAppService service)
        {
            this.service = service;
        }


        //---------------------------------------------------
        /// <summary>
        /// 调用递归获取物料产品分类
        /// </summary>
        /// <param name="sysName"></param>
        /// <param name="enAbled"></param>
        /// <returns></returns>
        //[HttpGet]
        public JsonResult GetMaterialType(string? sysName, int? enAbled)
        {
            var res = service.GetMaterialType(sysName, enAbled);
            return Json(new { data=res,count=res.Count,code=0,id=0,pid=0 });
        }


        /// 获取产品类型列表
        /// </summary>
        /// <param name="sysName"></param>
        /// <returns></returns>
        [HttpGet]
        public List<MaterialTreeDTO> GetMaterialProductsTypeList(string? sysName)
        {
            return service.GetMaterialProductsTypeList(sysName);
        }

        #endregion



        #region 视图
        public IActionResult MaterialView()
        {
            return View();
        }




        #endregion
    }
}
